// PostMessageMapper.java
package com.scuec.groupfive.mapper;

import com.scuec.groupfive.entity.Post;
import org.apache.ibatis.annotations.*;
import java.util.Date;
import java.util.List;

/**
 * 帖子数据统计Mapper
 */
@Mapper
public interface PostMessageMapper {
    // 获取有效帖子总数
    @Select("SELECT COUNT(*) FROM posts WHERE status = 1")
    int getTotalMessageCount();

    // 按时间范围获取帖子数量
    @Select("SELECT COUNT(*) FROM posts WHERE status = 1 AND created_at BETWEEN #{startDate} AND #{endDate}")
    int getMessageCountByDateRange(@Param("startDate") Date startDate, @Param("endDate") Date endDate);

    // 可选：获取帖子列表（如果需要）
    @Select("SELECT * FROM posts WHERE status = 1")
    List<Post> getAllPosts();
}